package day11;

import java.util.Scanner;

public class Main2 {
    public int getLCA(int a, int b) {
        // write code here
        if(a / 2 == b / 2) {
            return a / 2;
        }
        if(a / 2 == b) {
            return b;
        }
        if(a == b / 2) {
            return a;
        }
        return getLCA(a / 2,b / 2);
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNextInt()) { // 注意 while 处理多个 case
            int a = in.nextInt();
            int[] arr = new int[32];
            for(int i = 0; i < 31; i++) {
                arr[i] = 1 & a;
                a = a >> 1;
            }
            int max = 0;
            for(int i = 0; i < 31; i++) {
                int count = 0;
                if(arr[i] == 1) {
                    count++;
                    for(int j = i+1; j < 31; j++) {
                        if(arr[j] == 1) {
                            count++;
                        }else {
                            break;
                        }
                    }
                }
                if(max < count) {
                    max = count;
                }
            }
            System.out.println(max);
        }
    }
}
